#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
    int n = 0;
    int m = 0;
    scanf("%d %d", &n, &m);
    int nm[n][m];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &nm[i][j]);
        }
    }

    int x = 0;
    int boo = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &x);
            if (boo == 0)
            {
                if (x != nm[i][j])
                {
                    boo = 1;
                }
            }
        }
    }

    if (boo == 1)
    {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }

    return 0;
}